from pygraph.classes.graph import graph
from pygraph.classes.digraph import digraph
from pygraph.algorithms.searching import breadth_first_search
from pygraph.readwrite.dot import write
import pickle
from pygraph.algorithms.minmax import shortest_path
import sys

infname=sys.argv[1]
fromlink=sys.argv[2]
tolink=sys.argv[3]

inf=open(infname,"r")
gr=pickle.load(inf)
inf.close()

(stree,distance)=shortest_path(gr,fromlink)

curlink=tolink
while not stree[curlink] is None and curlink!=fromlink:
    print curlink," <- "

    curlink=stree[curlink]

if curlink==fromlink:
    print fromlink
